package homework.student.coding;

public class Project {
    private int intId;
    private String strProjectName;
    private int  intProjectYear;
    private Student[] arrayStudents;
    private int intStuNum;
    public Project(){}
    public Project(int intId,String strProjectName,int intProjectYear){
        this.setIntId(intId);
        this.setStrProjectName(strProjectName);
        this.setIntProjectYear(intProjectYear);
    }

    public void showProjectMesg(){
        System.out.printf("专业名称：%s  专业编号：%d  学制年限：%d%n",this.getStrProjectName(),this.getIntId(),this.getIntProjectYear());

    }
    public void addStudent(Student student){
        for (int i=0;i<this.getArrayStudents().length;i++)
        {
            if (this.getArrayStudents()[i]==null){
                this.getArrayStudents()[i]=student;
                student.setProject(this);
                this.intStuNum=i+1;
                 break;
            }
        }
    }
    public void showStudent(){
        for (Student stu: this.getArrayStudents()){
            if (stu==null){
                break;
            }
            stu.showStudentMesg();
            System.out.println("======================");

        }
        System.out.printf("本专业有%d名学生",this.getIntStuNum());
    }




    public int getIntId() {
        return intId;
    }

    public void setIntId(int intId) {
        this.intId = intId;
    }

    public String getStrProjectName() {
        return strProjectName;
    }

    public void setStrProjectName(String strProjectName) {
        this.strProjectName = strProjectName;
    }

    public int getIntProjectYear() {
        return intProjectYear;
    }

    public void setIntProjectYear(int intProjectYear) {
        this.intProjectYear = intProjectYear;
    }

    public Student[] getArrayStudents() {
        if (this.arrayStudents==null){
            this.arrayStudents=new Student[100];
        }
        return arrayStudents;
    }

    public void setArrayStudents(Student[] arrayStudents) {
        this.arrayStudents = arrayStudents;
    }

    public int getIntStuNum() {
        return intStuNum;
    }

    public void setIntStuNum(int intStuNum) {
        this.intStuNum = intStuNum;
    }
}
